import { createRouter, createWebHistory } from 'vue-router'
import NotFound from '../views/NotFound/NotFound.vue'
// import { useUserStore } from '../stores/modules(kaikai)/user'
console.log(import.meta.env.DEV)

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      component: () => import('@/views/login/LoginPages.vue')
    },
    {
      path: '/',
      component: () => import('@/views/layout/LayoutContainer.vue'),
      redirect: '/test/monitor',
      children: [
        {
          path: '/test/monitor',
          component: () => import('@/views/test/TestMonitor.vue')
        },
        {
          path: '/test/uppic',
          component: () => import('@/views/test/TestUppic.vue')
        },
        {
          path: '/species',
          component: () => import('@/views/species/SpeciesPage.vue')
        },
        {
          path: '/records',
          component: () => import('@/views/records/RecordsPage.vue')
        }
      ]
    },
    { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound }
  ]
})

//登录拦截  路由守卫
// router.beforeEach((to) => {
//   const useStore = useUserStore()
//   if (!useStore.token && to.path !== '/login') return '/login' 
//   //已登录或者已在登录页则直接放行
// })

export default router
